package com.enseirb.bdxmap.dao;

import java.util.List;

import com.enseirb.bdxmap.dao.dto.AbstractMarkerDTO;
import com.enseirb.bdxmap.dao.parser.AbstractMarkerParser;
import com.enseirb.bdxmap.dao.webrequest.WebServiceRequestManager;
import com.enseirb.bdxmap.exception.BdxMapException;

public abstract class AbstractMarkerDAO<T extends AbstractMarkerDTO, P extends AbstractMarkerParser<T>>
		implements MarkerDAO {
	protected String serviceUrl;

	public List<T> getData() throws BdxMapException {
		WebServiceRequestManager requestmanager = new WebServiceRequestManager();
		String json;

		json = requestmanager.request(serviceUrl);

		P parser = newServiceParser();
		List<T> list = parser.createDTO(json);
		return list;
	}

	protected abstract P newServiceParser();
}
